import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ConfigService } from './config.service';
import { Book } from '../model/book';
import { b } from '@angular/core/src/render3';

@Injectable()
export class CourseService {

  constructor(private http:HttpClient
    ,private config:ConfigService) { }



    private addBookUrl = this.config.host +"/manage/addBook";
    addBook(book:Book){

     return this.http.post(this.addBookUrl,book).toPromise();

    }

    private deleteBookUrl = this.config.host+ "/manage/deleteBook";
    deleteBook(book:Book){
      return this.http.post(this.deleteBookUrl,book).toPromise();
    }

    private updateBookUrl = this.config.host+ "/manage/updateBook";
    updateBook(book:Book){
      return this.http.post(this.updateBookUrl,book).toPromise();
    }

    private getOneBookUrl = this.config.host+ "/manage/getOneBook";
    getOneBook(book:Book){
      return this.http.post(this.getOneBookUrl,book).toPromise();
    }

    public getBookListUrl = this.config.host+"/public/getBookList";
    getBookList(){
      return this.http.get(this.getBookListUrl).toPromise();
    }


   private getCourseListByParmUrl = this.config.host + "/public/getCourseListByParm";
   getCourseListByParm(key:string,value:string){
    let parm= {
      "key":key,
      "value":value
    }

    return this.http.post(this.getCourseListByParmUrl,parm).toPromise();






   }


}
